<?php
class MoneyModeChild extends MoneyMode{
 
    //交易历史明细
    /*
     * param $type 1表示导出数据不用page 
     */
    function getList($user_id = null,$event_type = null,$rows = 15,$offset = 0,$start_time=null,$end_time=null,$type=null){
        $rows=(int)$rows;
        $offset=(int)$offset;
        $condition='';
        if(!empty($user_id)){
            $condition.=" AND (`user_id`=".(int)$user_id.")";
        }
        switch($event_type){
            case 'all':$condition.=" AND `event_type` = ' '";break;
            case 'in':$condition.=" AND `money`>=0";break;
            case 'out':$condition.=" AND `money`<0";break;
            case 'share':$condition.=" AND `event_type` = 'share'";break;
            case 'buy':$condition.=" AND `event_type` = 'buy'";break;
            case 'serviceFee':$condition.=" AND `event_type` = 'serviceFee'";break;
            case 'shopSell':$condition.=" AND `event_type` = 'shopSell'";break;
            case 'platsystem':$condition.=" AND `event_type` = 'platsystem'";break;
            default:$condition.='';
        }
        
        if($start_time){
            $condition.=" AND `create_time` >= '$start_time' ";
        }
        
        if($end_time){
            $condition.=" AND `create_time` <= '$end_time' ";
        }
        
        if(!$type){
            $limit=" LIMIT $offset,$rows";
        }else{
            $limit="";
        }
        $sql="SELECT SQL_CALC_FOUND_ROWS * FROM `money_history`
              WHERE 1 AND `enable` = 1 $condition
              ORDER BY `create_time` DESC".$limit;
        return $this->db->getList($sql,$user_id);
    }
     function getCashList($rows = 30,$offset = 0,$start_time=null,$end_time=null,$user_id=null){
        $rows=(int)$rows;
        $offset=(int)$offset;
        $user_id=(int)$user_id;
        $condition="";
        if($user_id){
            $condition.=" AND `user_id`='$user_id' ";
        }
        $sql="SELECT SQL_CALC_FOUND_ROWS * FROM `user_cash` WHERE 1".$condition."  ORDER BY `create_time` DESC LIMIT $offset,$rows";
        return $this->db->getList($sql);
    }
    
} 